package com.zoe.app.controller;

import cn.hutool.json.JSONObject;
import com.zoe.app.annotation.LogArgs;
import com.zoe.app.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zbg
 * @date 2023/05/30
 * @description
 */
@RestController
public class ArgsController {
    @GetMapping("/one-args")
    @LogArgs
    // http://localhost:8080/one-args?name=%E5%BC%A0%E4%B8%89
    public JSONObject oneArgs(String name) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.set("name", name);
        return jsonObject;
    }

    @GetMapping("/two-args")
    @LogArgs
    // http://localhost:8080/two-args?name=%E5%BC%A0%E4%B8%89&age=18
    public JSONObject twoArgs(String name, Integer age) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.set("name", name);
        jsonObject.set("age", age);
        return jsonObject;
    }

    @GetMapping("/two-args-oneobj")
    @LogArgs
    // http://localhost:8080/two-args-oneobj?name=%E5%BC%A0%E4%B8%89&age=18&userName=李四&userAge=19
    public JSONObject TwoArgsOneobj(String name, Integer age, User user) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.set("name", name);
        jsonObject.set("age", age);
        jsonObject.set("user", user);
        return jsonObject;
    }
}
